<?php

function checkSessionTimeOut() {

    $_loginLimit = 900;

    if ($_SESSION['lastLogin'] != null) {
        $_lastLogin = $_SESSION['lastLogin'];
    } else {
        header("Location: index.php");
    }
    $_currentTime = mkTime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
    if ($_currentTime - $_lastLogin > $_loginLimit) {
        session_destroy();
        header("Location: index.php");
    } else {
        unset($_SESSION['lastLogin']);
        $_lastLogin = $_currentTime;
        $_SESSION['lastLogin'] = $_lastLogin;
    }
}

?>